#ifndef OTHERRY_H_
#define OTHERRY_H_

class OtherRY {
	public:
		//error checking
		// false if exist a cart item with non-existent product
		static bool isCartItemValid(vector<Cart_item> pCart_items, vector<Product> pProds)
		{
			int iCartItems,iProds;
			bool found;
			for (iCartItems=0;iCartItems<pCart_items.size();iCartItems++)
			{
				iProds = 0;
				found = false;
				while (iProds<pProds.size() && !found)
				{
					if (pProds.at(iProds).getprodid() == pCart_items.at(iCartItems).getprodid()) {
						found = true;
					}
					iProds++;
				}
				if (!found)
					return false;
			}
			return true;
		}
		
		// false if exist a cart with no cart_item
		static bool isCartValid(vector<Cart> pCarts, vector<Cart_item> pCart_items)
		{
			int iCarts,iCartItems;
			bool found;
			for (iCarts=0;iCarts<pCarts.size();iCarts++)
			{
				iCartItems = 0;
				found = false;
				while (iCartItems<pCart_items.size() && !found)
				{
					if (pCart_items.at(iCartItems).getcartid() == pCarts.at(iCarts).getcartid()) {
						found = true;
					}
					iCartItems++;
				}
				if (!found)
					return false;
			}
			return true;
		}
		
		// false if exist a product with price less than zero
		static bool isProductValid(vector<Product> pProds)
		{
			int iProds;
			for (iProds=0;iProds<pProds.size();iProds++)
			{
				if (pProds.at(iProds).getprodprice() < 0) {
					return false;
				}
			}
			return true;
		}
};

#endif //OTHERRY_H_